package work;
import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Wokd extends JPanel{
    public static final int WIDTH = 641;
    public static final int HEIGHT = 479;
    private Battleship ship = new Battleship();
    private SeaObject[] submarines ={
            new OSubmarine(),
            new TpSubmarine(),
            new MineSubmarine()
    };
    private SeaObject[] thunders={
            new Tp(100,20),
            new Mine(200,110)
    };
    private Bomb[] boms ={};

    /** 重写paint()画  g:画笔 */
    public void paint(Graphics g){
        images.sea.paintIcon(null,g,0,0); //画海洋图
        ship.paintImage(g); //画战舰
        for(int i=0;i<submarines.length;i++){ //遍历所有潜艇
            submarines[i].paintImage(g); //画潜艇
        }
        for(int i=0;i<thunders.length;i++){ //遍历所有雷
            thunders[1].paintImage(g); //画雷
        }
        for(int i=0;i<boms.length;i++){ //遍历所有深水炸弹
            boms[i].paintImage(g); //画深水炸弹
        }
    }




    public static void main(String[] args) {
        JFrame frame = new JFrame(); //3.
        Wokd world = new Wokd();
        world.setFocusable(true);
        frame.add(world);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(641+16, 479+39);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);


    }
}
